<div class="row tab-content-row" id="metaGenObjAttrs_M_DIV">
    <div class="col-md-1"></div>
    <div class="col-md-10">
        <div class="box box-primary" >
            <div class="box-header">
              <h3 class="box-title">元对象[${entity.objComment}(${entity.objName})]属性列表</h3>
              <div class="box-tools pull-right">
                <form class="form-inline">
                <div class="input-group">
                    <span class="input-group-addon">名称</span>
                    <input type="text" class="form-control"  placeholder="属性名称" id="attrName" name="attrName">
                </div>
                <div class="input-group">
                    <span class="input-group-addon">备注</span>
                    <input type="text" class="form-control"  placeholder="属性备注" id="attrComment" name="attrComment">
                </div>
                <div class="btn-group" >
                    <button type="button" class="btn  btn-success btn-sm" data-btn-type="search">查询</button>
                    <button type="button" class="btn  btn-warning btn-sm" data-btn-type="reset">重置</button>
                </div>
                <div class="btn-group" >
                    <button type="button" class="btn  btn-success btn-sm" data-btntype="add">新增</button>
                    <button type="button" class="btn  btn-warning btn-sm" data-btntype="edit">修改</button>
                    <button type="button" class="btn  btn-warning btn-sm" data-btntype="delete">删除</button>
                </div>
                </form>
                
              </div>
              <!-- /.box-tools -->
            </div>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding ">
              <table class="table table-bordered table-condensed table-striped mytable " id="metaGenAttrTable">
                
              </table>
            </div>
            <!-- /.box-body -->
            <div class="box-footer box-footer-condensed clearfix">
              <div class=" no-margin-top">
                <span class="pagination_record_title" id="prt_metaGenAttrPage"></span>
                <ul class="pagination  pagination-sm pull-right no-margin pagination_ul" id="prl_metaGenAttrPage" ></ul>
              </div>
            </div>
            <!-- /.box-footer -->
          </div>
          <!-- /.box -->
    </div>
    
  <div class="modal fade" id="metaGenAttr_A_Model" data-reftableid="metaGenAttrTable"></div> 
  <div class="modal fade" id="metaGenAttr_E_Model" data-reftableid="metaGenAttrTable"></div>
</div>

<script>
  require([ "jquery", "bootstrap", "bootstrapTable","bootstrapTab_CH","validate"],function($) {
    var container = $("#metaGenObjAttrs_M_DIV");
    container.triggerEditView = function(id){
      container.find("#metaGenAttr_E_Model").load('${contextPath}/metaGenAttr/g2Edit/'+id,{},
        function(responseTxt,statusTxt,xhr){
            if(statusTxt=="success"){
                container.find("#metaGenAttr_E_Model").modal({
                    backdrop:false,
                    show:true
                });
            }  
            if(statusTxt=="error"){
              frameworkOptions.showInfoMessages(xhr);
            }     
        });
    }
    container.triggerAddView = function(){
      container.find("#metaGenAttr_A_Model").load('${contextPath}/metaGenAttr/g2Add/',{},
        function(responseTxt,statusTxt,xhr){
            if(statusTxt=="success"){
                container.find("#metaGenAttr_A_Model").modal({
                    backdrop:false,
                    show:true
                });
            }  
            if(statusTxt=="error"){
              frameworkOptions.showInfoMessages(xhr);
              
            }     
        });
    }  
    container.find('#metaGenAttrTable').bootstrapTable(
      {
        url : "${contextPath}/metaGenObj/queryObjAttrs",
        dataType : "json",
        pagination : false, //分页
        dataField : 'data.rows',
        noToolBar : true,//新增 是否不显示原生的工具栏 
        customPagination : true,//新增 是否启用自定义分页
        customPaginationTitleSelector : "#prt_metaGenAttrPage", //新增 客户分页统计信息容器的JQUERY选择器
        customPaginationListSelector : "#prl_metaGenAttrPage", //新增 客户分页条的JQUERY选择器 
        queryParams : function(params) {
          return {
            pageSize :(params.limit || 15),
            pageNum : (params.offset || 1),
            objId:${entity.id},
            attrName : container.find('#attrName').val().trim(),
            attrComment : container.find('#attrComment').val().trim()
          }
        },
        singleSelect : false,
        //search : true, //显示搜索框
        sidePagination : "client", //服务端处理分页
        columns : [
            {
              field : 'id',
              align : 'center',
              width : 30,
              title : '<label class="mylabel"></label>',
              formatter : function(value,row, index) {
                var checkbox = '<label class="mylabel" id="'+value+'"></label>';
                return checkbox;
              }
            },

            {
              title : '名称',
              field : 'attrName',
              align : 'left',
              valign : 'middle'
            },
            {
              title : '备注',
              field : 'attrComment',
              align : 'left',
              valign : 'middle',
            },
            {
              title : '详情',
              field : 'attrName',
              align : 'left',
              formatter : function(value,row, index) {
                var d = '';
                if(row.relationType == '1:N' || row.relationType == 'N:N' ){
                    d +=(row.relationType || 'List') +"< <span class='label label-default tooltopcss' data-toggle='tooltip' title='"+row.attrType+"'>"+row.attrShortTypeName+"</span>> "+value +" ;";
                }else{
                    d +=" <span class='label label-default tooltopcss' data-toggle='tooltip' title='"+row.attrType+"'>"+row.attrShortTypeName+"</span> "+value +" ;";
                }
                return d;
              }
            },
            {
              title : '操作',
              field : 'id',
              align : 'center',
              formatter : function(value,row, index) {
                var d = '<a href="#"  class="refAttr" data-rowid="'+row.id+'">编辑</a>|<a href="#" mce_href="#" class="delOne" id="'+row.id+'">删除</a> ';
                return d;
              }
            } ]
    });
    container.find('button[data-btntype="edit"]').on('click',{},function(e){
        var ids = new Array();
        container.find('#metaGenAttrTable tbody .mylabel').each(function(index,obj){
            if($(obj).data('checked')){
                ids.push(obj.id);
            } 
        });
        if(ids && ids.length>0){
            container.triggerEditView(ids[0]);
        }else{
          frameworkOptions.showInfoMessages("请选择一条记录");
            
        }

    });
    //初始化
    container.find('.tooltopcss').tooltip({
        delay : {
            show : 500,
            hide : 100,
        },
        container : 'body'
    });
    //销毁调用container.find('.tooltopcss').tooltip('destroy');
    container.find('button[data-btntype="add"]').on('click',{},function(e){
        
      container.triggerAddView();
        

    });
    
  });
</script>